25 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
26 #define For(i, a, b) for (int i=(a); i<(b); ++i)
27 #define D(x) cout << #x " is " << x << endl
29 typedef pair
< double, double > interval
;
31 const double eps
= 1e-9;
33 const int MAXN
= 1001;
35 interval intervals
[MAXN
];
38 void delete_redundant() {
40 for (int i
= 0; i
< B
; ++i
) {
41 for (int j
= 0; j
< B
; ++j
) {
43 // delete interval j if interval i is completely inside it
44 if (intervals
[j
].first
< intervals
[i
].first
- eps
and intervals
[i
].second
+ eps
< intervals
[j
].second
) {
50 for (int i
= 0; i
< B
; ++i
) {
51 if (!deleted
[i
]) intervals
[k
++] = intervals
[i
];
59 for (int i
= 0; i
< B
; ++i
) {
61 cin
>> x1
>> y1
>> x2
>> y2
;
62 double t1
= atan2(y1
, x1
), t2
= atan2(y2
, x2
);
63 intervals
[i
] = make_pair( min(t1
, t2
), max(t1
, t2
) );
66 sort(intervals
, intervals
+ B
);
68 for (int i
= 0; i
< B
; ) {
70 double pick
= intervals
[i
].second
;
71 while (i
< B
and intervals
[i
].first
- eps
< pick
) i
++;